package cn.yyj.springsecurity02.web;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

@RestController
public class UserController {

    @RequestMapping("/userInfo1")
    public Principal principal(Principal principal){
        return principal;
    }

    @RequestMapping("/userInfo2")
    public Authentication userInfo2(){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        return authentication;
    }
}